package cn.mw.cmdb.template.entity.export;

import cn.mw.cmdb.template.constant.MwTemplateConfigurationConstant;
import cn.mw.cmdb.template.enums.ZabbixMonitorTypeEnum;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

/**
 * @author gengjb
 * @description 监控项导出实体
 * @date 2024/9/3 15:52
 */
@Getter
@Setter
@Schema(name = "MonitorItemExportDto", description = "监控项导出实体")
public class MonitorItemExportDto {
    private String itemid;

    @ExcelProperty(value = {"监控项名称"})
    private String name;

    @ExcelProperty(value = {"键值"})
    private String key_;

    @ExcelProperty(value = {"间隔"})
    private String delay;

    @ExcelProperty(value = {"历史记录"})
    private String history;

    @ExcelProperty(value = {"趋势"})
    private String trends;

    @ExcelProperty(value = {"类型"})
    private String type;

    @ExcelProperty(value = {"状态"})
    private String status;

    public void setStatus(String status) {
        if(StringUtils.isNotEmpty(status) && Integer.parseInt(status) == 0){
            this.status = MwTemplateConfigurationConstant.ENABLED;
            return;
        }
        if(StringUtils.isNotEmpty(status) && Integer.parseInt(status) == 1){
            this.status = MwTemplateConfigurationConstant.NOT_ENABLED;
            return;
        }
        this.status = status;
    }

    public void setType(String type) {
        if(StringUtils.isNotEmpty(type)){
            ZabbixMonitorTypeEnum monitorTypeEnum = ZabbixMonitorTypeEnum.getMonitorTypeEnum(type);
            if(monitorTypeEnum != null){
                this.type = monitorTypeEnum.getName();
                return;
            }
        }
        this.type = type;
    }
}
